<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="Canvas 仿黑客帝国 404 界面
    
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }
        #canvas {">
<meta property="og:type" content="website">
<meta property="og:title" content="jeniusLi's blog">
<meta property="og:url" content="http://yoursite.com/404/index.html">
<meta property="og:site_name" content="jeniusLi's blog">
<meta property="og:description" content="Canvas 仿黑客帝国 404 界面
    
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }
        #canvas {">
<meta property="og:updated_time" content="2017-03-11T01:27:58.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="jeniusLi's blog">
<meta name="twitter:description" content="Canvas 仿黑客帝国 404 界面
    
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }
        #canvas {">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/404/"/>





  <title>
  

  
     | jeniusLi's blog
  
</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container one-collumn sidebar-position-left  ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">jeniusLi's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">生活、技术个人博客</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
  <header class="post-header">

	<h1 class="post-title" itemprop="name headline"></h1>



</header>

    
    
      <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Canvas 仿黑客帝国 404 界面</title>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
        }
        #canvas {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <canvas id="canvas"></canvas>
    <script>
        function RainBy404(elc, str, size){
            if(typeof elc == "string") elc = document.querySelector(elc);

            // 动画函数
            var fastAnimation = function (fn) {
                return requestAnimationFrame ||
                        webkitRequestAnimationFrame ||
                        mozRequestAnimationFrame ||
                        function (callback) {
                            setTimeout(callback, 1000 / 60);
                        };
            }();

            // 文字像素化
            function str2matrix(str, w, h){
                var matrix = [];
                for(var i = 0; i < w; i++){
                    matrix[i] = [];
                    for(var j = 0; j < h; j++){
                        matrix[i][j] = 0;
                    }
                }

                var canvas = document.createElement("canvas");
                canvas.width = w;
                canvas.height = h;
                var context = canvas.getContext("2d"),
                    fontSize = w * 0.3 / str.length,
                    imgData = [];

                context.fillStyle = "white";
                context.fillRect(0, 0, w, h);

                context.fillStyle = "black";
                context.font = fontSize + "px Calibri";
                context.textBaseline = "middle";
                context.fillText(str, (w - context.measureText(str).width) / 2, h / 2);

                try {
                    imgData = context.getImageData(0 ,0, w, h).data;
                } catch(e){

                }

                for(var i = 0; i < imgData.length; i+=4){
                    r = imgData[i];
                    g = imgData[i+1];
                    b = imgData[i+2];
                    gray = r*0.2126 + g*0.7152 + b*0.0722; //RGB转YUV

                    matrix[parseInt(i / 4 % w)][parseInt(i / 4 / w)] = gray < 250 ? 1 : 0;
                }

                return matrix;
            }

            // 定义水滴对象
            function Drop(str, x, y, rows){
                this.i = 0;
                this.s = Math.random()*10+"";
                this.x = x || 0;
                this.y = y || 0;
                this.rows = rows;
            }
            Drop.prototype = {
                constructor: Drop,

                getChar: function(){
                    return this.s.charAt(this.i % this.s.length);
                },

                reset: function(){
                    this.i = 0;
                    this.y = 0;
                },

                drop: function(){
                    this.i++;
                    this.y++;
                    if(this.y > this.rows && Math.random() > 0.975) this.reset();
                }
            }

            // 初始化参数
            var cols = Math.round(elc.width / size);
            var rows = Math.round(elc.height / size);
            var drops = [];
            var matrix = null;
            var context = elc.getContext("2d");

            function draw(){
                // 画布覆盖
                context.fillStyle = "rgba(0,0,0,0.05)";
                context.fillRect(0, 0, elc.width, elc.height);

                // 水滴描绘
                drops.forEach(function(drop){
                    context.fillStyle = (matrix && matrix[drop.x][drop.y]) ? "red" : "rgb(0, 97, 14)";
                    context.font = size + "px Calibri";
                    context.fillText(drop.getChar(), drop.x * size, drop.y * size);
                    drop.drop();
                })

                // 重复绘制
                fastAnimation(draw);
            }

            function start(){
                // 生成水滴
                for(var i = 0; i < cols; i++){
                    var drop = new Drop(str, i, 0, rows);
                    drops.push(drop);
                }

                // 生成像素信息
                matrix = str2matrix(str, cols, rows);

                // 画布覆盖
                context.fillStyle = "black";
                context.fillRect(0, 0, elc.width, elc.height);
                // 重复绘制
                draw();
            }

            return {
                start: start
            }
        }

        var canvas = document.querySelector("#canvas");
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        var rain = new RainBy404(canvas, "404", 12);
        rain.start();
    </script>
</body>
</html>

    
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/jenius.jpeg"
               alt="Jenius" />
          <p class="site-author-name" itemprop="name">Jenius</p>
           
              <p class="site-description motion-element" itemprop="description">主要是学习后端技术，学过Java web、python web等后台技术</p>
          
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jenius</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  





  



  
  

  

  

  

  


  

</body>
</html>
